import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' +
'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='

const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' +
'7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' +
'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' +
'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' +
'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' +
'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' +
'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' +
'UP8iWi1Qw0Y='

// 支付类

const publicKey2 = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAluy1lHWFoqHNtUl/X4mhwMiCTXQTdHuSAMTY8qhvmcBB9Q66FFXHX+vX2TAIoYZkGA4l6ZAZxfkNC8xouc7/enhq8CdWGUZz4CUxKJXPkJfeKP3ZmlYYXvFDZJE2ms869axKi0k98WbDKZIIUmb8crB/Zv0IUO/RyrX12vywCIImCBQHeiJHSMKlNBL0ZfTE5wjtg2cC/DdcmRwLbDpJD/ru2F6onzVLIJqD/SMweM5wK9ydgUaTzC9dYkxcUjH6F0Ob8hOFSwBYWIPRVWjL5N28zhSAfcz1w82CchnAvIn+s0MvA6B6NiurTvGrk7GA6ioBPsIW7ZpUolu3hb1c+QIDAQAB'

const privateKey2 = 'MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAIPDSn8C3DP8lKDKqr4rYx09bONBTxAkOZ/0O4zDbORTcJcByXfjbIxn/pHPUMU4NGKAvkARFsNe4GCLkvn78SrZmnh3jxayQAyRcze/Nwz1hprCwbLO/pEqxqDANqSE5xXhua2b3nWXMA8Gsq5i6ELBAWkbtdgpXLXmpcZVmCcvAgMBAAECgYBPsVBfXYV90+i5D5sRhgBecQZotNly89X+jqNt0c0MlALm8me+IUlH6qYn3nIFtqbIZQGskiloZPvkqMZueBk2aR1hToDoJh+BAVBR0dI1q06b5PUiPjyP39ZjQ2W1jWJ0JAgUncY9BvIG1ya8nDxL2j9hNPSyMBo6mhxs+Rd8IQJBAMAtocjPPGzWr1V/+T1284+Nsx698qjPqPYCdyAPo/EtJtrHF30c7Q6ZmKTmbG5xj39pC6J2/HObzoMcuWDpSjcCQQCvhVbYRp+R8kn4RR334A8Usoacm0v6iCYxFU/23sB9QDiIuOU2FBEvyklR/YYzmHoy40YUNc8cYCbY6uBOIS7JAkBOmVs1+ixIh3WmjnStwtzSta2wwRdiG6yLEW8PWdY/aawehpcAwLfj5MYdi3CFq0R5Y8kyZV/TGMJZtYHMNR35AkAShxrBvcK+XzsbsAAX2Fj/MFExWttMWO7fI4bLYnwjPJI7LHlVmgyuZMYUl5SBAcl0cbVGEOAJ+MRhBXokBTCxAkABPfltp+SR9bEupwm2W+ggnUjUrbuwIGUULviWge50GGPT0xUkJPY1EkuR4hyyrsZ6bwMyKl+QldLlzsOysw+3'

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

// 支付加密
export function encrypt2(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey2) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 支付解密
export function decrypt2(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey2) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

